package com.example.shopping.dao;

import com.example.shopping.pojo.Content;
import com.example.shopping.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
Create by 苍狼 于 2020/1/16
站在巅峰看世界，
落在深渊思人生。
*/
//广告管理
@Repository
public interface IContentDao {
    //广告信息全部查询
    @Select("select * from content")
    List<Content> selectContentList();

    //删除
    @Delete("delete from content where id=#{id}")
    int deleteContentById(int id);

    @Select("select * from content where id=#{id}")
    Content selectContentByIdOne(int id);
    //新增广告
    @Insert("insert into content(category_id,title,url,pic,status,sort_order) values(#{categoryId},#{title},#{url},#{pic}.#{status},#{sortOrder})")
    int insertContent(Content content);

    //修改
    @Update("update content set category_id=#{categoryId}, title=#{title},url=#{url},sort_order=#{sortOrder},pic=#{pic},status=#{status} where id=#{id}")
    int updateContent(Content content);

    //按照关联id查找
    @Select("select * from content where category_id=#{categoryId}")
    List<Content> selectContentById(int categoryId);
    //修改为开启状态
    @Update("update content set status=2 where id=#{id}")
    int updateContentStatusClose(int id);

    //修改为关闭状态
    @Update("update content set status=1 where id=#{id}")
    int updateContentStatusOpen(int id);
}
